home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / source / point_2d.cp < prev    next >
Encoding:
Text File  |  1995-03-25  |  3.0 KB  |  65 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    point_2d.cp
  3. //    Date:                    11/07/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a (u, v) point_2d
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "point_2d.h"
  11. #include "vector_2d.h"
  12.  
  13. //------------------------------------------------------------------------------
  14. //    global variables
  15. //------------------------------------------------------------------------------
  16. point_2d    ORIGIN_2D (R(0.0), R(0.0));                                                                                        //    the origin of the coordinate system
  17.  
  18. //------------------------------------------------------------------------------
  19. //    constructor
  20. //------------------------------------------------------------------------------
  21. point_2d::point_2d (real x, real y) : tuple_2d (x, y)                                                        //    normal constructor
  22. {                                                                                                                                                                //    begin
  23. }                                                                                                                                                                //    end
  24.  
  25. //------------------------------------------------------------------------------
  26. //    constructor
  27. //------------------------------------------------------------------------------
  28. point_2d::point_2d (const point_2d &p) : tuple_2d (p)                                                        //    copy constructor
  29. {                                                                                                                                                                //    begin
  30. }                                                                                                                                                                //    end
  31.  
  32. //------------------------------------------------------------------------------
  33. //    constructor
  34. //------------------------------------------------------------------------------
  35. point_2d::point_2d (const vector_2d &v) : tuple_2d (v)                                                        //    constructor from a 2d vector
  36. {                                                                                                                                                                //    begin
  37. }                                                                                                                                                                //    end
  38.  
  39. //------------------------------------------------------------------------------
  40. //    assignment operator
  41. //------------------------------------------------------------------------------
  42. point_2d    &point_2d::operator = (const point_2d &p)                                                            //    assignment operator
  43. {                                                                                                                                                                //    begin
  44.     tuple_2d::operator = (p);
  45.     return *this;
  46. }                                                                                                                                                                //    end
  47.  
  48. //------------------------------------------------------------------------------
  49. //    vector addition operator
  50. //------------------------------------------------------------------------------
  51. point_2d    point_2d::operator + (const vector_2d &v) const                                                //    add a vector to a point
  52. {                                                                                                                                                                //    begin
  53.     return point_2d (xy[X] + v[X], xy[Y] + v[Y]);
  54. }                                                                                                                                                                //    end
  55.  
  56. //------------------------------------------------------------------------------
  57. //    subtraction operator
  58. //------------------------------------------------------------------------------
  59. vector_2d    point_2d::operator - (const point_2d &p) const                                                //    subtract two points
  60. {                                                                                                                                                                //    begin
  61.     return vector_2d (xy[X] - p[X], xy[Y] - p[Y]);
  62. }                                                                                                                                                                //    end
  63.  
  64. //------------------------------------------------------------------------------
  65.